class TextMessage {
  String requestId;
  int inputTokens;
  int outputTokens;
  int totalTokens;
  String finishReason;
  String role;
  String content;
  int type;

  TextMessage(this.requestId, this.inputTokens, this.outputTokens,
      this.totalTokens, this.finishReason, this.role, this.content, this.type);

  TextMessage.fromJson(Map<String, dynamic> json)
      : requestId = json['requestId'] as String,
        inputTokens = json['inputTokens'] as int,
        outputTokens = json['outputTokens'] as int,
        totalTokens = json['totalTokens'] as int,
        finishReason = json['finishReason'] as String,
        role = json['role'] as String,
        content = json['content'] as String,
        type = 0;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'requestId': requestId,
        'inputTokens': inputTokens,
        'outputTokens': outputTokens,
        'totalTokens': totalTokens,
        'finishReason': finishReason,
        'role': role,
        'content': content,
        'type': type,
      };

  static TextMessage create(String content, int type) {
    return TextMessage("${DateTime.timestamp().millisecond}", 0, 0, 0, "null",
        "user", content, type);
  }

  static TextMessage copy(TextMessage source) {
    return TextMessage(
        source.requestId,
        source.inputTokens,
        source.outputTokens,
        source.totalTokens,
        source.finishReason,
        source.role,
        source.content,
        source.type);
  }
}
